var runSearch = function(event, url) {
    if (event.keyCode == 13) {
    	searchPaging(url);
    }
}

var searchPaging = function(url) {
	var keyword = $("#search-input").val();
	/*
	$.post(url, {
		"page" : 1,
		"keyword" : keyword
	}, function(data, status) {
		//
	});
	*/
	window.location.replace(url + "?keyword=" + encodeURI(keyword));
};

var showPage = function(url, page, sectionId, pagingBtnIdPrefix) {
	$("#" + sectionId).load(url, {"page" : page}, function(){		
		$("#" + pagingBtnIdPrefix + page).addClass("curPage");
		// 重新绑定 重组的dom的js效果 依赖于jq.hoverdir --黄广杰25/5/2015 
		if($("#da-thumbs").get(0)){
			$("#da-thumbs li .list-item-l").hoverdir({
		        hoverDelay: 50,
		        hoverElem: ".item-img div"
		    });
		}
	});	
};

var goPage = function(url, maxPage, goPageId, sectionId, pagingBtnIdPrefix) {
	var targetPage = $("#" + goPageId).val();
	
	if(targetPage !== null || targetPage !== undefined || targetPage !== ''){
		if(parseInt(targetPage) < parseInt(maxPage)){
			showPage(url, targetPage, sectionId, pagingBtnIdPrefix);
		}else{
			showPage(url, maxPage, sectionId, pagingBtnIdPrefix);
		}		
	}
	// 重新绑定 重组的dom的js效果 依赖于jq.hoverdir --黄广杰25/5/2015
	if($("#da-thumbs").get(0)){
		$("#da-thumbs li .list-item-l").hoverdir({
	        hoverDelay: 50,
	        hoverElem: ".item-img div"
	    });
	}
};

$(document).ready(
  function() {
	$("a[id$=\"page_btn_1\"]").addClass("curPage");//for all paging start button
  }
);
